-
-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Per Request Cache #681
base: master
Are you sure you want to change the base?
Per Request Cache #681
Conversation
Add another layer of in memory cache. Avoids pinging the "real" cache for the same request.
Same as with UserDefaultChecker, it avoids pinging the real cache multiple times for the same request.
Update RoleDefaultChecker.php
I have a question, it's wrapping the whole logic with array driver cache, so it's basically loading the data in memory for the whole request, so it only hits the real cache once per request, is that right? |
Thats correct. Even better solution might be the Laravel Once helper |
Yes, the once helper was introduced in version 11.X. I believe there is an issue with your approach, if we run this in a worker, the permissions will be cached "forever" until they are restarted. |
Interesting, i am using Vapor serverless so havent even thought of something like that. Have you verified that the array cache persists between queue jobs on same worker? |
This would allow for in memory caching instead of pinging the "real" cache store each time. Noticed large number of requests when using Laravel Nova with Laratrust. When Nova is checking the policies (which check user permissions and roles) it makes 100+ requests which is unnecessary for single request.
Before
After
Captures from Laravel Telescope